package org.brisling.satisfaction.service;

import org.brisling.common.ConstSysParam;
import org.brisling.medical.domain.MedicalInpatient;
import org.brisling.medical.domain.MedicalOutpatient;
import org.brisling.satisfaction.domain.SatisfactionEvaluateMessage;
import org.brisling.satisfaction.queryService.QuerySatisfactionEvaluateMessageService;
import org.brisling.satisfaction.service.base.BaseSatisfactionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/satisfactionEvaluateMessage")
/**
 * 满意度答题者个人信息service
 * @Author : SherlockMoon
 * @Date   : 2016年8月02日
 * @version: 1.0
 */
public class SatisfactionEvaluateMessageService extends BaseSatisfactionService<SatisfactionEvaluateMessage>{
		
	@Autowired
	private QuerySatisfactionEvaluateMessageService qryService;
	
	
	public SatisfactionEvaluateMessageService(){
		this.clazz = SatisfactionEvaluateMessage.class;
		this.moduleName = ConstSysParam.MODULE_SATISFACTION_EVALUATE_MESSAGE;	
		this.subSystem = ConstSysParam.SUBSYSTEM_STATISFACTION;
	}
	
	/**
	 *保存评价者个人信息
	 * @param SatisfactionEvaluateMessage
	 */
	public SatisfactionEvaluateMessage save(SatisfactionEvaluateMessage indi){
		SatisfactionEvaluateMessage obj= super.save(indi);
		if(obj!=null && obj.getId()!=null)
			return qryService.getOne(obj.getId());
		return null;
	}
	
	
	public SatisfactionEvaluateMessage saveInpatientMessage(MedicalInpatient inpatient) {
		SatisfactionEvaluateMessage obj = new SatisfactionEvaluateMessage();
		obj.setPatient_id(inpatient.getPatient_id());
		obj.setHospital_code(inpatient.getHospital_code());
		obj.setHospital_name(inpatient.getHospital_name());
		obj.setPatient_code(inpatient.getPatient_no());
		obj.setPatient_name(inpatient.getPatient_name());
		obj.setDepart_code(inpatient.getDoct_depart_code());
		obj.setDepart_name(inpatient.getDoct_depart_name());
		obj.setEvaluate_type(2L);
		return this.save(obj);
	}
	
	public SatisfactionEvaluateMessage saveOutpatientMessage(MedicalOutpatient outpatient) {
		SatisfactionEvaluateMessage obj = new SatisfactionEvaluateMessage();
		obj.setPatient_id(outpatient.getOutpatient_number());
		obj.setHospital_code(outpatient.getHospital_code());
		obj.setHospital_name(outpatient.getHospital_name());
		obj.setPatient_code(outpatient.getPatient_no());
		obj.setPatient_name(outpatient.getPatient_name());
		obj.setDepart_code(String.valueOf(outpatient.getDoct_depart_code()));
		obj.setDepart_name(outpatient.getDoct_depart_name());
		obj.setEvaluate_type(1L);
		return this.save(obj);
	}
	
}


